/*
	Copyright (c) 2010 <copyright holders>
	This source code is licensed under The MIT License,
	see the file LICENSE for details.
	*/

#ifndef CLIENTLOGIC_HPP
#define CLIENTLOGIC_HPP

#include "Client.hpp"

namespace spelprog2 {
namespace net {
namespace client_logic {

//! Base class for client logic.
class ClientLogic : public net::NetMessageListener {
protected:
    Client & client_;
    ClientLogic(Client & client) : net::NetMessageListener(), client_(client) { }
};


//! Simply passes on messages to Client's primary registry.
struct PassOn : public ClientLogic {
    PassOn(Client & client) : ClientLogic(client) { }
    virtual void onMessage(MessagePtr msg, const NetMessageInfo & info);
};


//! Handles a LoginReply message.
struct HandleLogin : public ClientLogic {
    HandleLogin(Client & client) : ClientLogic(client) { }
    virtual void onMessage(MessagePtr msg, const NetMessageInfo & info);
};


//! Reads a ServerVarChange message and updates net vars accordingly.
struct HandleVarChange : public ClientLogic {
    HandleVarChange(Client & client) : ClientLogic(client) { }
    virtual void onMessage(MessagePtr msg, const NetMessageInfo & info);
};


//! Reads a UserChange message and updates users accordingly.
struct HandleUserChange : public ClientLogic {
    HandleUserChange(Client & client) : ClientLogic(client) {}
    virtual void onMessage(MessagePtr msg, const NetMessageInfo & info);
};


}; //namespace client_logic
}; //namespace net
}; //namespace spelprog2

#endif //CLIENTLOGIC_HPP